<?php
if(isset($_GET['postmsg']) && isset($_GET['postdst'])) { 
$names = preg_split("/_/", $_GET['postdst']);
if(strcmp($names[0], $names[1]) >=0 ) {
	$postdst = "$names[0]_$names[1]";
}
else
	$postdst = "$names[1]_$names[0]";

$fp = fopen("chat/$postdst","a+");
fwrite($fp,$_GET['postmsg']."<BR>");
fclose($fp);
}
else {
	echo "something wrong<BR>";
	if(!isset($_GET['postmsg']))
		echo "postmsg not set<BR>";
	if(!isset($_GET['postdst']))
		echo "postdst not set<BR>";
}
?>
<body OnLoad="document.post.postmsg.focus();">
<form name="post" action="post.php" method="get">
Message:<Input type="text" size=50 name=postmsg autocomplete=off>
</INPUT><Input type="submit" value="send" onclick="document.post.postmsg.value=parent.left.document.data.local.value+':'+document.post.postmsg.value;return;">
<input type="hidden" name=postdst value=""></input>
</form>
<script lang=javascript type='text/javascript'> 
	document.post.postdst.value= parent.left.document.data.local.value+"_"+parent.left.document.data.remote.value;
	//parent.history.historyform.test.value="cde";
	//parent.historysrc.window.location.reload(true);
	parent.historysrc.document.location.href="history.php?loadid="+document.post.postdst.value;
</script>
</body>
